package com.mmall.controller;

import java.math.BigDecimal;

import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mmall.common.JsonResponse;

import com.mmall.pojo.User;
import com.mmall.service.IUserService;

@Controller
@RequestMapping("/user/")
public class UserController {
	@Autowired
	private IUserService userService;
	
	@RequestMapping(value= "test.do",method=RequestMethod.GET)
	@ResponseBody
	public JsonResponse test() {
		User user = new User();
		user.setUsername("zhang");
	
//		BigDecimal priceDe = new BigDecimal(price);
//		BigDecimal d = priceDe.multiply(new BigDecimal(quantity));
		JSONObject json = new JSONObject();
//		json.append("total", d);
		
		return JsonResponse.successResponse(user);
//		return user;
	}
	
	@RequestMapping(value="allUser.do", method=RequestMethod.GET)
	@ResponseBody
	public JsonResponse allUser() {
		return userService.userList();
		
	}
}
